// 2013-7-29下午04:55:42  net.betou.trade.main.manager.impl.NoticeTypeMngImpl.java

package net.betou.trade.main.manager.impl;

import java.util.List;

import net.betou.common.hibernate3.Updater;
import net.betou.trade.entity.main.NoticeType;
import net.betou.trade.main.dao.NoticeTypeDao;
import net.betou.trade.main.manager.NoticeTypeMng;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 
 * @author 叶装装
 */
@Service
@Transactional
public class NoticeTypeMngImpl implements NoticeTypeMng{

	public NoticeType deleteById( Integer id ) {
		return dao.deleteById( id );
	}

	public NoticeType[ ] deleteByIds( Integer [ ] ids ) {
		NoticeType [ ] beans = new NoticeType[ ids.length ];
		
		for( int i = 0; i < ids.length; i++ ){
			beans[ i ] = dao.deleteById( ids[ i ] );
		}
		return beans;
	}
	
	@Transactional( readOnly = true )
	public NoticeType findByAgent( ) {
		return dao.findByIdentity( "a" );
	}
	@Transactional( readOnly = true )
	public NoticeType findById( Integer id ) {
		return dao.findById( id );
	}
	@Transactional( readOnly = true )
	public NoticeType findBySystem( ) {
		return dao.findByIdentity( "s" );
	}

	public List< NoticeType > getList( String searchProperty, String searchValue, String orderProperty, String orderDirection ) {
		return dao.getNoticeTypeList( searchProperty, searchValue, orderProperty, orderDirection );
	}

	public NoticeType save( NoticeType bean ) {
		bean.init( );
		dao.save( bean );
		return bean;
	}

	public NoticeType update( NoticeType bean ) {
		
		bean.init( );
		Updater< NoticeType > updater = new Updater< NoticeType > ( bean, Updater.UpdateMode.MIN );
		updater.include( "name" );
		updater.include( "description" );
		dao.updateByUpdater( updater );
		return bean;
	}
	
	@Autowired
	private NoticeTypeDao dao;

}
